/*
  decoding.hh
*/

#include "BasicRingBuffer.hh"
#include "CryptoPrimitive.hh"

/* ringbuffer size */
#define DECODE_RB_SIZE (1024)
/* max write buffer size */
#define FWRITE_BUFFER_SIZE (4*1024*1024)

using namespace std;

class Decoder {
public:
	typedef struct{
		Decoder* obj;
	}param_decoder;

	typedef struct{
		unsigned char* data;
		int blockSize;
	}Block_t;

	typedef struct{
	    unsigned char* data;
	    int blockcpSize;
	    unsigned char key[32];
            int left;
	}BlockCp_t;

	RingBuffer<BlockCp_t>* inputbuffer_;
    pthread_t tid_;

    int totalBlocks_;

    FILE* fp_;

    CryptoPrimitive* cryptoObj_;

    Decoder(int n,int m,int r);

    ~Decoder();

    int setTotal(int total);

    int add(BlockCp_t* blockcp);

    int indicateEnd();

    int setFilePointer(FILE* fp);
    static void* thread_hander(void * param);


};
